package com.lfx.concurrent;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;

public class CompletTableFutureMain7 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<String> stringCompletableFuture1 = CompletableFuture.supplyAsync(() -> {
            try {
                Thread.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return "返回结果";
        }).thenCombine(CompletableFuture.supplyAsync(new Supplier<String>() {
            @Override
            public String get() {
                return "22222";
            }
        }), new BiFunction<String, String, String>() {
            @Override
            public String apply(String s, String s2) {
                System.out.println("参数1:"+s);
                System.out.println("参数2:"+s2);
                return "lala";
            }
        });

        String s = stringCompletableFuture1.get();
        System.out.println("result"+s );

    }
}
